Skip to content

Fix mask editor sometimes showing wrong image#12413

Merged
AustinMroz merged 5 commits into
mainfrom
austin/fe-811-incorrect-mask-editor-image
May 25, 2026
Merged

Fix mask editor sometimes showing wrong image#12413
AustinMroz merged 5 commits into
mainfrom
austin/fe-811-incorrect-mask-editor-image

Conversation

@AustinMroz
Copy link
Copy Markdown
Collaborator

Mask editor checks node.images to determine the image which is edited. If the user generates an output image in litegraph mode, swaps to vue mode, then generates a new image, the mask editor will incorrectly display the image last shown in litegraph mode.

This is resolved by having syncLegacyNodeImgs also synchronize node outputs to node.images.

Playwright is once again non-functional, so test is likely to be broken
as well
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR syncs persisted node image outputs into legacy litegraph nodes by assigning node.images from stored outputs and adds a Playwright E2E that simulates executed events (via a merged WebSocket fixture) to verify preview filenames update and the mask editor opens with the current preview.

Changes

Stale Preview Prevention

Layer / File(s) Summary
Node images legacy synchronization
src/stores/nodeOutputStore.ts
syncLegacyNodeImgs now retrieves stored node outputs via getNodeOutputs(node) and assigns node.images from outputs.images when present, alongside existing node.imgs and node.imageIndex updates.
Stale preview E2E test
browser_tests/tests/maskEditor.spec.ts
Added merged Playwright/WebSocket test harness and new test Will not use stale litegraph previews that dispatches executed events with image filenames, polls the Preview Image node output filename before/after toggling Comfy.VueNodes.Enabled, and asserts the mask editor dialog becomes visible.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit nudges the canvas bright,
Sends events that make previews light,
Old names fall away with grace,
New images take their place,
The mask pops up — a happy sight! 🐇✨

🚥 Pre-merge checks | ✅ 5 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description explains the problem and solution but lacks several template sections (Summary, Changes with What/Breaking/Dependencies, Review Focus, and issue link). Consider following the template more closely: add a one-sentence summary, structure changes under What/Dependencies, highlight any design decisions, and link to the issue (#811) if applicable.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix mask editor sometimes showing wrong image' directly and clearly describes the main bug being fixed in this changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
End-To-End Regression Coverage For Fixes ✅ Passed PR title contains bug-fix language ("Fix") and changes src/stores/nodeOutputStore.ts, but includes E2E regression test changes in browser_tests/tests/maskEditor.spec.ts.
Adr Compliance For Entity/Litegraph Changes ✅ Passed No files under src/lib/litegraph/, src/ecs/, or graph entity classes were modified. Changes are confined to src/stores/nodeOutputStore.ts, which is outside ADR scope per check instructions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch austin/fe-811-incorrect-mask-editor-image

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 05/22/2026, 10:27:27 PM UTC

Links

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

🎭 Playwright: ✅ 1638 passed, 0 failed · 2 flaky

📊 Browser Reports
  • chromium: View Report (✅ 1617 / ❌ 0 / ⚠️ 2 / ⏭️ 5)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 18 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@browser_tests/tests/maskEditor.spec.ts`:
- Around line 312-320: The test currently hardcodes node id '1' in the
dispatched event and the getNodeOutput lookup; instead capture the created
node's id (e.g., assign the returned node's id to a variable like createdNodeId)
and use that variable when building the detail object passed to
app!.api.dispatchCustomEvent('executed', ...) and when querying the page.
Replace graph!.getNodeById('1') with a dynamic lookup that uses createdNodeId;
if calling page.evaluate, pass createdNodeId as an argument into the evaluate
callback to avoid relying on closure scope.
- Line 313: Remove the stray debug console.error call
(console.error(JSON.stringify(detail))) from the test; locate it in
maskEditor.spec.ts (the test path containing the JSON.stringify(detail) call)
and either delete the line or replace it with a non-error logging mechanism
(e.g., console.debug or a test-only logger) so test success runs do not emit
error-level console output that can break CI.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c02c5c72-edfa-449d-bbf1-1bfb8f1c1aba

📥 Commits

Reviewing files that changed from the base of the PR and between 0a07781 and 4053bc6.

📒 Files selected for processing (2)
  • browser_tests/tests/maskEditor.spec.ts
  • src/stores/nodeOutputStore.ts

Comment thread browser_tests/tests/maskEditor.spec.ts Outdated
Comment thread browser_tests/tests/maskEditor.spec.ts Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@             Coverage Diff             @@
##             main   #12413       +/-   ##
===========================================
- Coverage   74.35%   60.12%   -14.23%     
===========================================
  Files        1522     1415      -107     
  Lines       85827    72453    -13374     
  Branches    23516    20130     -3386     
===========================================
- Hits        63814    43562    -20252     
- Misses      21198    28418     +7220     
+ Partials      815      473      -342     
Flag Coverage Δ
e2e ?
unit 60.12% <100.00%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/stores/nodeOutputStore.ts 48.94% <100.00%> (-30.45%) ⬇️

... and 1027 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 22, 2026
@AustinMroz AustinMroz marked this pull request as ready for review May 22, 2026 01:47
@AustinMroz AustinMroz requested a review from a team May 22, 2026 01:47
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 22, 2026
Comment thread browser_tests/tests/maskEditor.spec.ts Outdated
)
})

test('Will not use stale litegraph previews', async ({ comfyPage }) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test isnt inside a describe and doesn't actually test any mask editor functionality so probably better elsewhere or open the mask editor at the end to validate that it is the correct image

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment got eaten 😭

I agree. There's not a (non screenshot/route mock) way to test the image loaded by the mask editor, but the prior structure of the test actually worked out nicely here.

Tragically, the existing mask editor fixture code isn't helpful since it forcibly loads a different workflow.

Comment thread browser_tests/tests/maskEditor.spec.ts Outdated
await comfyPage.menu.topbar.newWorkflowButton.click()
await comfyPage.searchBoxV2.addNode('Preview Image')

async function simulateExecuted(image: object) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe worth adding this to ExecutionHelper?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like ExecutionHelper already had a function to do this and my grep fu had failed me. The fixture code feels a good bit clunkier to use here, but tests an even broader scope which is appreciated.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
browser_tests/tests/maskEditor.spec.ts (1)

316-330: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use the created node id instead of hardcoded '1'.

Line 318, Line 322, and Line 329 hardcode the node id, which makes this regression test brittle if id allocation changes. Capture the created Preview Image node id and reuse it for both executed(...) and getNodeById(...).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@browser_tests/tests/maskEditor.spec.ts` around lines 316 - 330, The test
hardcodes node id '1' in getNodeOutput (which calls graph!.getNodeById),
executionHelper.executed, and the second executed call; instead capture the id
of the created Preview Image node when you create it (store it in a variable
like previewNodeId) and reuse that variable in getNodeOutput,
executionHelper.executed, and any other place that referenced '1' so the test is
resilient to id allocation changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@browser_tests/tests/maskEditor.spec.ts`:
- Around line 316-330: The test hardcodes node id '1' in getNodeOutput (which
calls graph!.getNodeById), executionHelper.executed, and the second executed
call; instead capture the id of the created Preview Image node when you create
it (store it in a variable like previewNodeId) and reuse that variable in
getNodeOutput, executionHelper.executed, and any other place that referenced '1'
so the test is resilient to id allocation changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd1dfcb4-1042-4f5d-a1b8-13df57f7276f

📥 Commits

Reviewing files that changed from the base of the PR and between 76fbde9 and 5c7f54e.

📒 Files selected for processing (1)
  • browser_tests/tests/maskEditor.spec.ts

@AustinMroz AustinMroz added this pull request to the merge queue May 25, 2026
Merged via the queue into main with commit fb5b4a6 May 25, 2026
49 checks passed
@AustinMroz AustinMroz deleted the austin/fe-811-incorrect-mask-editor-image branch May 25, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants